#!/usr/bin/env node

const { timeEnd } = require('console');
const http = require('http'),
    fs = require('fs'),
    {join}  = require('path');

http.createServer((req,res) => {
    console.time('TEXT')
    //console.log(req.url)
    let file = join(_dirfile,req.url)
    //console.log(file)
    if(!fs.existsSync(file)){
        res.end(`${req.url} not exists`);
        return;
    }
    fs.readFile(file,(err,data) => {
        if(err){
            res.end('wrong');
        }else{
            console.timeEnd('TEXT')
            res.end(data)
        }
    });
    res.end('ok')
}).listen(8080)